from django.conf.urls import url
from django.urls import path
from rest_framework.routers import DefaultRouter

from api.views import send_code_by_sms, DistrictView, \
    HotCityView, HouseTypeViewSet, AgentViewSet, EstateViewSet, \
    HouseInfoViewSet, TagViewSet, UserViewSet, login, ProvinceView

urlpatterns = [
    path('token/', login),
    path('mobile_code/<str:tel>/', send_code_by_sms),
    # url(r'^mobile_code/(?P<tel>1[3-9]\d{9})/$', send_code_by_sms),
    # path('districts/', get_provinces),
    path('districts/', ProvinceView.as_view()),
    path('districts/<int:pk>/', DistrictView.as_view()),
    path('hotcities/', HotCityView.as_view()),
]

router = DefaultRouter()
router.register('housetypes', HouseTypeViewSet)
router.register('agents', AgentViewSet)
router.register('estates', EstateViewSet)
router.register('tags', TagViewSet)
router.register('houseinfos', HouseInfoViewSet)
router.register('users', UserViewSet)

urlpatterns += router.urls
